home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 525 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.production.compuserve.com!news
  2. From: Dave Hand <70621.3624@CompuServe.COM>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Poor floating point code in BC++
  5. Date: 4 Jan 1996 22:37:04 GMT
  6. Organization: Singular Software, Inc.
  7. Message-ID: <4chkqg$bve$1@mhadf.production.compuserve.com>
  8. References: <DKnMHr.IqA@uns.bris.ac.uk>
  9.  
  10. > Not necessarily, as I pointed out in a previous post, a fistp
  11. > is insufficent if the rounding mode is unknown, or known not
  12. > to be round to zero. Conversion of a float to an int must 
  13. > produce the value closer to zero (because the standard says 
  14. > so). Such a restriction is not required for other floating
  15. > point arithmetic, because the C standard does not say anything
  16. > about rounding.
  17.  
  18. > Many C systems permit the rounding mode to be set by a call, 
  19. > it appears that borland C is one such system.
  20.  
  21. You are correct that you need to set the RC flag in the NPX 
  22. control word, but my point was that there is no need for a 
  23. function call. Also, the rounding mode only needs to be set 
  24. once. By using in-line assembly, I found that the cast could be 
  25. done about 4 times faster and was just wondering if any other 
  26. compilers did a better job of generating floating point code. 
  27.  
  28. The default RC flag for BC is 00 (ie round to nearest integer), 
  29. and I have not found a way to change this outside assembly code. 
  30. You indicated that there is a way to do this?
  31.  
  32. Thanks for the input.   
  33.  
  34.